/**
 * Description:
 * Class Name:EnumTest
 * Date:2022/2/12 14:43
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第6章_面向对象_下._6_9_枚举类._6_9_2_枚举类入门;

public class EnumTest {
    public void judge(SeasonEnum s){
        // switch 表达式中可以是枚举值
        switch (s){
            case SPRING -> {
                System.out.println("春暖花开，正值踏青");
            }
            case SUMMER -> {
                System.out.println("夏日炎炎，适合游泳");
            }
            case FALL -> {
                System.out.println("秋高气爽，进补及时");
            }
            case WINTER -> {
                System.out.println("冬日飘雪，围炉夜话");
            }
        }
    }

    public static void main(String[] args) {
        // 枚举类默认有一个values()方法，返回该枚举类的所有实例，它遇上println会自动打印实例的字面值，使用的是该枚举值的toString()方法
//        System.out.println(SeasonEnum.SPRING.toString());
//        System.out.println(SeasonEnum.SPRING.name());
//        System.out.println(SeasonEnum.SPRING.ordinal());
//        SeasonEnum a = SeasonEnum.valueOf("SUMMER");
//        System.out.println(a);
//        System.out.println("---------");
//        System.out.println(SeasonEnum.SPRING.compareTo(SeasonEnum.FALL));
//        System.out.println(SeasonEnum.valueOf(SeasonEnum.class, "SUMMER"));
        for (var s:
             SeasonEnum.values()) {
            System.out.println(s);
        }
        // 使用枚举类时，可通过EnumClass.variable形式来访问
        new EnumTest().judge(SeasonEnum.SPRING);
    }
}
